import { initData } from '@/utils/api'
export const state = () => ({
  list: [],
  me: '123'
})

export const mutations = {
  add (state, text) {
    state.list.push({
      text,
      done: false
    })
  },
  remove (state, { todo }) {
    state.list.splice(state.list.indexOf(todo), 1)
  },
  toggle (state, todo) {
    todo.done = !todo.done
  }
}

export const actions = {
  SET_SETTING_ITEM ({ commit }, payload) {
    commit('SET_SETTING_ITEM', payload)
  },
  GetInfo ({ commit }, payload) {
    return new Promise((resolve, reject) => {
      console.log(payload.a, '=============')
      initData(payload.axios).then((res) => {
        resolve()
      }).catch((error) => {
        reject(error)
      })
    })
  }
}
